Decimation of fixed length queues

ABSTRACT

Decimation of data from a fixed length queue retaining a representative sample of the old data. Exponential decimation removes every nth sample. Dithered exponential decimation offsets the exponential decimation approach by a probabilistic amount. Recursive decimation selects a portion of the queue and removes elements.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention deals with fixed-length queues in computerhardware and software. More specifically, the present invention dealswith techniques for managing fixed-length queues when they become full.

2. Art Background

Many systems use fixed-length queues to buffer data between a dataproducer and a data consumer. If the consumer is not able to consumedata as fast as the producer places it in the queue, or is unable forsome reason to take data from the queue or empty the queue, the queuecan become full. The queue management system, hardware or software, musthave policies in place for dealing with queue overflow situations.

Traditional approaches to queue overflow include techniques such asoverwriting the last item, dropping the oldest item, or discarding thenewest item. The choice is usually made based on the needs of theapplication and the presumed importance of new data versus old data.

SUMMARY OF THE INVENTION

Techniques for decimation, the removal of old data, from a fixed lengthqueue retain a representative sample of the data. Exponential decimationremoves every nth sample. Dithered exponential decimation applies anoffset to the exponential decimation approach. Recursive randomdecimation selects a portion of the queue and removes elements, andrecurses on the remaining portion of the queue.

BRIEF DESCRIPTION OF THE DRAWINGS

The present invention is described with respect to particular exemplaryembodiments thereof and reference is made to the drawings in which:

FIG. 1 shows a fixed length queue,

FIG. 2 shows exponential decimation in a fixed length queue, and

FIG. 3 shows recursive decimation in a fixed length queue.

DETAILED DESCRIPTION

FIG. 1 shows a fixed length queue 100 of 10 elements, where each item inthe queue is represented by its sample number. Element 1 is the oldestelement in the queue, element 2 the next oldest, and so on throughelement 10 which is the newest. Queue 100 is full. When a new itemarrives, either the new item must be discarded, or room must be made forit in the queue. Prior art solutions to adding a new item to a fullqueue include discarding the new item, and overwriting the most recentlyadded item. The approach used depends on the needs of the application,and the presumed importance of old data versus new data.

Decimation as taught by the present invention trades reduced accuracyfor increased apparent size of the queue. For example, if a 60 elementqueue contains samples taken every second, the queue when full holdssamples spanning a minute, with one sample for every second in thatminute. After many rounds of applying the decimation techniquesaccording to the present invention, the same 60 element queue holds datacovering a time span equivalent to that of a queue many times that size.However, the queue no longer contains a sample for each second of thattime span.

The embodiments of the present invention may be implemented in a widerange of software, ranging from microcode or very low-levelimplementations to high-level language implementations. Embodiments ofthe present invention may also be implemented directly in hardware.

It should be understood that truly random numbers are very difficult togenerate, and that the term random in this context is understood to be ashorthand for pseudorandom numbers. The generation of pseudorandomnumbers is well understood in the art, described at length for examplein Chapter 3 of The Art of Computer Programming by Donald E. Knuth.

Exponential decimation removes samples from the queue in such a way thatold data is removed at the expense of new data, while still maintaininga representative sampling of the old data. An example of exponentialdecimation is shown in FIG. 2. Fixed length queue 200 is full.Exponential decimation by n=2 removes every second sample before addinga new item, removing items 2, 4, 6, 8, and 10 from queue 200 to producequeue 210 New samples are added until the queue once again is full,shown in 220. Decimation is repeated and a new sample added, removingevery second item, namely items 3, 7, 11, 13, and 15, producing queue230. As decimation continues, the distribution of the data becomesexponential in nature.

Exponential decimation can also be applied with divisors other than n=2and can begin with any item in the queue, effectively adjusting theexponential rate of decay of old data in the queue. While exponentialdecimation may be applied to a queue removing multiple elements at onetime, as shown in FIG. 2, it may also be practiced removing one elementat a time. This requires that the decimation process retain statebetween invocations. As an example, consider the case of a 10 elementqueue and divisor n=2. The first time the decimation process is called,the item in position 2 of the queue is removed. The next time thedecimation process is called, the item in position 4 of the queue isremoved, then the item in position 6, then the item in position 10, andthen the item in position 2 once again. Applying the decimation processgradually in this manner essentially allows the queue to remain full atall times once it has initially been filled, eliminating old items onlywhen necessary

Exponential decimation may also be dithered, probabilistically adding(or subtracting) a dither offset m to the sample position to be removed.At each position a probability of offsetting is calculated. As anexample with the case of exponential decimation with a divisor of n=2and an offset of m=1, samples at positions 2, 5, 7, and 8 in the queueare removed, rather than positions 2, 4, 6, and 8. Dithered exponentialdecimation gives the same emphasis to old data, but is less susceptibleto sample bias. In the general case of dithered exponential decimationwhere the divisor is n and the dither value is ±m, the distributionfunction should ideally be uniform with a zero mean, but anydistribution will do.

Another method of removing data from a full queue according to thepresent invention is recursive decimation. This is shown in FIG. 3. 300shows a full queue of 16 items. Recursive decimation begins by dividingthe queue in half. If the queue size is not an integer power of 2, somemethod can be used to make it a power of two in all rounds but thefirst. For example, assume the queue size is s and let m=└log₂ (s)┘.Then the older “half” of the queue contains the oldest 2^(m) elementsand the newer “half” contains the rest. Select the newer half of thequeue, shown as 310 with items 9-16 in bold, and delete a point atrandom, shown in 320 with item 10 replaced by an X.

The process is repeated recursively with the remaining half of thequeue, shown in 330. The newer half is selected, items 5-8 in 340. Anelement is deleted at random, item 7 replaced by an X in 350. Recursivedecimation continues in the same fashion with 360-380.

390-410 represent the end of the recursive process. When the queue sizebeing examined is equal to two, one of the elements is deleted at randomand the recursive process terminated.

The overall result of this example of random recursive decimation isshown as 420. As with exponential decimation, recursive decimation maybe applied over the entire queue, recursively decimating successivelysmaller portions of the queue, or it may be applied one recursive roundat a time, maintaining state between rounds. Again, applying thedecimation process gradually in this manner essentially allows the queueto remain full at all times once it has initially been filled,eliminating old items only when necessary

As stated, certain aspects of the computation are simplified if thequeue length in recursive decimation is an integer power of 2. While arandom number may be generated each time an element is to be deleted, ifthe queue size is indeed an integer power of 2, a single randomlygenerated number may suffice, since in a sufficiently random number allbits in a binary representation will be random.

As an example, consider a queue containing 64 elements. In the firstrecursion, a random position spanning items 33 to 64 must be selected,requiring a random number in the range of 0-31. A random number isgenerated and five consecutive bits (either right most or leftmost) areselected to span the range 0-31. In the next round of recursion, therange needed is 0-15, so the next 4 bits of the random number are used.The next round uses 3 bits for a range of 0-7, the following round uses2 bits for 0-3, and the final round uses 1 bit. In total then,5+4+3+2+1=15 bits are needed in total. In general, the number of bits kneeded for a queue of size n is:$k = \frac{{\log(n)}^{2} - {\log(n)}}{2}$

This approach generates a single random number and does not reuse bits.While the possibility of introducing sample bias is increased, analternate approach is to generate a single random number with at leastthe number of bits required for the first round of recursion, and reusethat random number in succeeding rounds, selecting fewer bits for eachround.

If the size of the queue is not an integer power of 2, random numbersmay be generated individually for each round of recursive decimation, ora single random number may be generated and reused in successive stages,for example by taking the random number modulo the queue size at issuein each round.

The foregoing detailed description of the present invention is providedfor the purpose of illustration and is not intended to be exhaustive orto limit the invention to the precise embodiments disclosed. Accordinglythe scope of the present invention is defined by the appended claims.

1. (canceled)
 2. (canceled)
 3. (canceled)
 4. (canceled)
 5. (canceled) 6.(canceled)
 7. (canceled)
 8. (canceled)
 9. (canceled)
 10. (canceled) 11.(canceled)
 12. (canceled)
 13. (canceled)
 14. (canceled)
 15. (canceled)16. (canceled)
 17. (canceled)
 18. (canceled)
 19. A method of replacingelements of a single fixed-length queue, the method comprisingexponentially decimating an element from the queue to create space for anew element, and inserting a new element into the created space.
 20. Amethod as in claim 19 and further comprising shifting the created spacetoward an end of the queue before inserting the new element.
 21. Amethod as in claim 19 wherein exponentially decimating comprisesremoving a plurality of elements from the queue to create a plurality ofspaces for new elements, and wherein inserting a new element comprisesinserting new elements into the created spaces.
 22. A method as in claim19 wherein exponentially decimating comprises dithering to select theelement to be decimated.
 23. A method of replacing elements of a singlefixed-length queue, the method comprising recursively selecting aportion of the queue, randomly selecting an element in the selectedportion, removing the selected element to create space for a newelement, and inserting a new element into the created space.
 24. Amethod as in claim 23 and further comprising repeating the foregoingsteps.
 25. A method as in claim 24 wherein randomly selecting an elementcomprises generating a pseudorandom number and using the generatednumber to select an element.
 26. A method as in claim 23 whereinrandomly selecting an element comprises generating a pseudorandom numberand using a first part of the generated number to select an element. 27.A method as in claim 26 and further comprising recursively selecting asecond portion of the queue, using a second part of the generated numberto select an element in the second portion of the queue, removing theselected element to create space for a new element, and inserting a newelement into the created space.
 28. A method as in claim 23 and furthercomprising shifting the created space toward an end of the queue beforeinserting the new element.
 29. An article of manufacture for replacingelements of a single fixed-length queue comprising a computer readablemedium and processor instructions contained on the computer readablemedium, the instructions configured to be readable by a processor and tocause the processor to decimate an element from the queue to createspace for a new element and to insert a new element into the createdspace.
 30. An article of manufacture as in claim 29 wherein theinstructions cause the processor to shift the created space toward anend of the queue before inserting the new element.
 31. An article ofmanufacture as in claim 29 wherein decimate comprises exponentiallydecimate.
 32. An article of manufacture as in claim 31 whereinexponentially decimate comprises remove a plurality of elements from thequeue to create a plurality of spaces for new elements, and wherein toinsert a new element comprises to insert new elements into the createdspaces.
 33. An article of manufacture as in claim 31 whereinexponentially decimate comprises dither to select the element to bedecimated.
 34. An article of manufacture as in claim 29 wherein decimatecomprises recursively select a portion of the queue, randomly select anelement in the selected portion, remove the selected element to createspace for a new element, and insert a new element into the createdspace.
 35. An article of manufacture as in claim 34 wherein decimatefurther comprises recursively select another portion of the queue,randomly select an element in the selected portion, remove the selectedelement to create space for a new element, and insert a new element intothe created space.
 36. An article of manufacture as in claim 34 whereinrandomly select an element comprises generate a pseudorandom number anduse the generated number to select an element.
 37. An article ofmanufacture as in claim 34 wherein randomly select an element comprisesgenerate a pseudorandom number and use a first part of the generatednumber to select an element.
 38. An article of manufacture as in claim37 wherein randomly select an element further comprises recursivelyselect a second portion of the queue, use a second part of the generatednumber to select an element in the second portion of the queue, removethe selected element to create space for a new element, and insert a newelement into the created space.